#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>

#define STACK_OVERFLOW	( 1)
#define STACK_EMPTY	(-1)
#define ST_MAXSIZE	(100000)

static struct stack {
	char data[ST_MAXSIZE];
	int top;
} st;

static const char op_br = "([<{";
static const char cl_br = ")]>}";

static int
stack__push(char c)
{
	extern struct stack st;

	if (st.top == ST_MAXSIZE - 1)
		return STACK_OVERFLOW;

	st.data[++st.top] = c;

	return 0;
}

static int
stack__pop(void)
{
	extern struct stack st;

	if (st.top < 0)
		return STACK_EMPTY;

	return st.data[st.top--];
}

char
reverse_assoc(char br)
{
}

int
main(int argc, char **argv)
{
	extern struct stack st;
	int c;
	int ret;

	st.top = -1;

	while (c = fgetc(stdin), (c != EOF && c != '\n')) {
		if (c == '(' || c == '[' || c == '<' || c == '{') {
			stack__push(c);
		} else {
			if (stack__pop() != (int) c) {
				fputs("NO\n", stdout);
				break;
			}
		}
	}

	if (stack__pop() != STACK_EMPTY) {
		fputs("NO\n", stdout);
	} else {
		fputs("YES\n", stdout);
	}

	return 0;
}
